package tests.delete;

import static org.junit.Assert.fail;

import model.Budget;
import model.BudgetFactory;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.workplicity.util.Helper;
import org.workplicity.worklet.WorkletContext;

/*
 * 
 * Attempts to delete a single budget
 * 
 */

public class BudgetDeleteTest00
{	
	Budget budget;
	BudgetFactory factory;

    /**
     * Default constructor
     */
    public BudgetDeleteTest00()
    {
    }

	@Before
	public void setUp() throws Exception
	{
	}

	@After
	public void tearDown() throws Exception
	{
	}

	@Test
	public void test()
	{
	 	 factory = new BudgetFactory();
         
	 	 try
		 {
             //Create a budget
 	         budget = (Budget) factory.create();
             budget.setName("Test budget");
             
             budget.setDescription("This is a delete test budget.");
             budget.commit();
              
             Boolean successful = Helper.delete(budget, "Budgets", WorkletContext.getInstance());
             
             if(!successful)
             {
            	 fail("Budget delete failed");
             }
         }
         catch(Exception e)
         {
             fail("Deleting budget failed with exception: " + e);
         }
     }
}
